

public class Animal {
    String type;
    int age;


    public void eat(){
        System.out.println("吃食物");
    }

    public void speak(){
        System.out.println("发出叫声");
    }

}


class Dog extends Animal{
   String name;
   public Dog(String name){
       type="狗";

       this.name=name;
       System.out.println("他是一只"+type+" 它的名字为:"+name);

   }

    public static void main(String[] args) {
        Dog dog=new Dog("旺财");
        dog.speak();
        dog.eat();

    }

        }
